#include <bits/stdc++.h>
#ifndef DEBUG
#define debug
#endif
using namespace std;
using i64 = int64_t;

const int mod = 998244353;
int main() {
  cin.tie(0)->sync_with_stdio(0);
  int n;
  cin >> n;
  vector<int> a(n + 1);
  for (int i = 1; i <= n; i ++) cin >> a[i];

  vector<vector<array<i64, 2>>> dp(n + 1, vector<array<i64, 2>>(n + 1, {0, 0}));
  for (int l = n; l >= 1; l --) {
    dp[l][l][0] = dp[l][l][1] = 1;
    for (int r = l + 1; r <= n; r ++) {
      dp[l][r][0] = dp[l][r][1] = dp[l + 1][r][1];
      for (int k = l + 1; k <= r; k ++) {
        if (a[k] > a[l]) {
          dp[l][r][1] = (dp[l][r][1] + dp[l][k - 1][0] * dp[k][r][1] % mod) % mod;
        }
      }
    }
  }
  cout << dp[1][n][0] << endl;
}